package com.xiukelai.springboot;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author hutao
 * @since 2019−07-25 下午 3:31
 */
@RestController
@RequestMapping(value = "hello")
public class HelloController {

    //1 .properties和.yml同时存在的时候，默认.properties优先

    //2 使用注解@Value，来获取yml配置的值
    @Value("${name}")
    private String name;

    @Value("${remark}")
    private String remark;

    @Value("${birthday}")
    private String birthday;

    @Value("${age}")
    private Integer age;

    @Value("${spring.profiles.active}")
    private String environment;

    //3 在配置文件中获取当前配置,具体参看yml
    @Value("${content}")
    private String content;

    @GetMapping(value = "/test")
    public String hello(@RequestParam Map map){
        for(Object key:map.keySet()){
            System.out.println(key+" = "+map.get(key));
        }
        System.out.println(this.name);
        System.out.println(this.remark);
        System.out.println(this.birthday);
        System.out.println(this.age);
        System.out.println(this.content);
        System.out.println("热部署只针对代码修改，不针对配置文件修改(mapper.xml文件也算配置文件)哦！！！");


        System.out.println("配置多运行环境");
        System.out.println("当前项目运行环境："+this.environment);

        return "测试-test-123456-!@#$%-！@#￥%-ok";
    }
}
